package com.diandian.backend.store.service;

import com.diandian.backend.store.domain.StoreElemeRetailStoreInfo;
import com.diandian.backend.store.dto.StoreElemeRetailStoreInfoAddParamDTO;
import com.diandian.backend.store.dto.StoreElemeRetailStoreInfoDeleteByIdParamDTO;
import com.diandian.backend.store.dto.StoreElemeRetailStoreInfoDetailParamDTO;
import com.diandian.backend.store.dto.StoreElemeRetailStoreInfoUpdateByIdParamDTO;
import com.diandian.backend.store.mapper.StoreElemeRetailStoreInfoMapper;
import com.diandian.backend.store.resp.StoreElemeRetailStoreInfoDetailResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class StoreElemeRetailStoreInfoService {

    @Autowired
    private StoreElemeRetailStoreInfoMapper storeElemeRetailStoreInfoMapper;

    public StoreElemeRetailStoreInfoDetailResp getDetail(StoreElemeRetailStoreInfoDetailParamDTO param) {

        StoreElemeRetailStoreInfo dbData = storeElemeRetailStoreInfoMapper.getDetail(param);
        if(dbData == null){
            return null;
        }

        StoreElemeRetailStoreInfoDetailResp result = new StoreElemeRetailStoreInfoDetailResp();
        result.setId(dbData.getId());
        result.setOfflineCode(dbData.getOfflineCode());
        result.setOnlineCode(dbData.getOnlineCode());
        result.setOnlineName(dbData.getOnlineName());
        result.setBelong(dbData.getBelong());
        result.setRemark(dbData.getRemark());
        result.setCreateUserId(dbData.getCreateUserId());
        result.setCreateUserName(dbData.getCreateUserName());
        result.setCreateTime(dbData.getCreateTime());
        result.setOrgId(dbData.getOrgId());
        result.setOrgCode(dbData.getOrgCode());
        result.setUpdateUserId(dbData.getUpdateUserId());
        result.setUpdateUserName(dbData.getUpdateUserName());
        result.setUpdateTime(dbData.getUpdateTime());
        result.setDel(dbData.getDel());
        result.setName(dbData.getName());
        result.setShopLogo(dbData.getShopLogo());
        result.setProvince(dbData.getProvince());
        result.setCity(dbData.getCity());
        result.setCounty(dbData.getCounty());
        result.setAddress(dbData.getAddress());
        result.setPhone(dbData.getPhone());
        result.setIvrPhone(dbData.getIvrPhone());
        result.setServicePhone(dbData.getServicePhone());
        result.setServicePhones(dbData.getServicePhones());
        result.setLongitude(dbData.getLongitude());
        result.setLatitude(dbData.getLatitude());
        result.setCoordType(dbData.getCoordType());
        result.setInvoiceSupport(dbData.getInvoiceSupport());
        result.setPackageBoxPrice(dbData.getPackageBoxPrice());
        result.setBusinessFormId(dbData.getBusinessFormId());
        result.setCategorys(dbData.getCategorys());
        result.setBusinessTime2(dbData.getBusinessTime2());
        result.setBizIdentity(dbData.getBizIdentity());
        result.setDeliveryTimeType(dbData.getDeliveryTimeType());
        result.setImData(dbData.getImData());
        result.setStatus(dbData.getStatus());
        return result;
    }

    public void updateBasicInfo(StoreElemeRetailStoreInfoUpdateByIdParamDTO param) {
        param.check();
        storeElemeRetailStoreInfoMapper.updateBasicInfo(param);
    }

    public void deleteById(StoreElemeRetailStoreInfoDeleteByIdParamDTO paramDTO) {
        paramDTO.check();
        storeElemeRetailStoreInfoMapper.deleteById(paramDTO);
    }

    public void add(StoreElemeRetailStoreInfoAddParamDTO param) {
        param.setCreateTime(new Date());
        param.setDel(0);
        storeElemeRetailStoreInfoMapper.add(param);
    }
}
